﻿using AiXiu.BLL;
using AiXiu.Common;
using AiXiu.IBLL;
using AiXiu.Model;
using System;
using System.Web.UI;

namespace AiXiu.WebSite
{
    /// <summary>
    /// 头像变更页
    /// </summary>
    public partial class AvatarEdit : Page
    {
        /// <summary>
        /// 更新按钮点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAvatar_Click(object sender, EventArgs e)
        {
            TBUsers user = IdentityManager.ReadUser();
            user.Avatar = hfAvatar.Value;
            IUserBLL userBLL = new UserBLL();
            var result=userBLL.EditAvatar(user);
            if(result.StatusCode== StatusCode.Succeed)
            {
                //更新缓存
                IdentityManager.SaveUser(user);
                //跳转到个人中心页面
                this.Redirect("succ","Personal.aspx");
            }
            else
            {
                this.Alert("fail", result.Message);
            }
        }
    }
}